@extends('web.frame_layout')
<?php $parent_menu = "财务中心"; $menu_selected = "会员转账";?>
@section('content')
    <div class="m-right-nr">
        <div>
            <h2><span>{{$menu_selected}}</span></h2>
            <div class="m-vip_trf">
                <form class="vip_trf" id="vip_trf" action="{{ route('web.transfer.act') }}" method="post"
                      autocomplete="on">
                    <ul>
                        <li>
                            <input name="_token" value="{{csrf_token()}}" type="hidden"/>
                            <label for="accept_user" class="hidden-xs"><i>*</i>接受账户：</label>
                            <input type="text" id="accept_user" name="accept_user" placeholder="请输入会员用户名">
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="wallet" class="hidden-xs"><i>*</i>选择钱包：</label>
                            <select id="wallet" name="wallet">
                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">
                                    奖金币钱包（{{ $wallet->w1 }}）
                                </option>
                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">
                                    报单币钱包（{{ $wallet->w2 }}）
                                </option>
                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_3}}">
                                    购物币钱包（{{ $wallet->w3 }}）
                                </option>
                            </select>
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="money" class="hidden-xs"><i>*</i>交易金额：</label>
                            <input type="text" id="money" name="money" placeholder="请输入交易金额">
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="safepass" class="hidden-xs"><i>*</i>交易密码：</label>
                            <input type="password" id="safepass" name="safepass" placeholder="请输入交易密码">
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <button>立即转账</button>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script>
        // 验证规则
        $('#vip_trf').validate({
            rules: {
                accept_user: {
                    required: true,
                    username: true
//        maxlength:6
                },
                wallet: {
                    required: true
//    digits:true,
//    min:100
                },
                money: {
                    required: true,
                    hundred: true
                },
                safepass: {
                    required: true,
                    password: true
                }
            },
            messages: {},
            errorPlacement: function (error, element) {
                $(element).siblings('.u-ts').html(error)
            },
            errorElement: 'span',
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    beforeSend: function () {
                        //禁用按钮,防止重复提交
                        $("button").attr('disabled', 'disabled')
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location = "{{ route('web.transfer.log') }}";
                            }, 2000);
                        } else {
                            $("button").removeAttr('disabled');
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });

        //    jQuery.validator.addMethod('password', function (value, element) {
        //    var password = /^[a-z0-9_-]{6,18}$/.test(value);
        //    return this.optional(element) || password
        //    }, '请输入6-18位字母，数字_-');

    </script>
@endsection